<div class="content-wrapper">

    <section class="content-header">
        <?php echo $this->partial('layout/breadcrumb'); ?>

        <h1 class="pull-right">
            <?php echo $this->HelpUrl('stockWarning'); ?>
        </h1>

    </section>

    <section class="content">
        <?php echo $this->partial('layout/messages'); ?>

        <div class="row">
            <div class="col-xs-12">
                <div class="box erp-box">
                    <div class="box-body table-responsive no-padding">
                        <table class="table table-hover">
                            <thead>
                            <tr class="erp-bg-thead">
                                <th width="25%"><?php echo $this->translate('商品名称'); ?></th>
                                <th width="15%"><?php echo $this->translate('商品编号'); ?></th>
                                <th width="16%"><?php echo $this->translate('商品规格'); ?></th>
                                <th width="10%"><?php echo $this->translate('商品分类'); ?></th>
                                <th width="10%"><?php echo $this->translate('商品品牌'); ?></th>
                                <th width="8%"><?php echo $this->translate('当前库存'); ?></th>
                                <th width="8%"><?php echo $this->translate('最低库存'); ?></th>
                                <th width="8%"><?php echo $this->translate('最高库存'); ?></th>
                            </tr>
                            <?php
                            $sForm = $this->searchForm;
                            $sForm->prepare();
                            ?>
                            <?php echo $this->form()->openTag($sForm); ?>
                            <tr>
                                <td>
                                    <?php echo $this->formElement($sForm->get('goods_name')); ?>
                                    <?php echo $this->formElementErrors($sForm->get('goods_name'), ['class'=>'error-message']);?>
                                </td>
                                <td>
                                    <?php echo $this->formElement($sForm->get('goods_number')); ?>
                                    <?php echo $this->formElementErrors($sForm->get('goods_number'), ['class'=>'error-message']);?>
                                </td>
                                <td>
                                    <?php echo $this->formElement($sForm->get('goods_spec')); ?>
                                    <?php echo $this->formElementErrors($sForm->get('goods_spec'), ['class'=>'error-message']);?>
                                </td>
                                <td>
                                    <?php echo $this->formElement($sForm->get('goods_category_id')); ?>
                                    <?php echo $this->formElementErrors($sForm->get('goods_category_id'), ['class'=>'error-message']);?>
                                </td>
                                <td>
                                    <?php echo $this->formElement($sForm->get('brand_id')); ?>
                                    <?php echo $this->formElementErrors($sForm->get('brand_id'), ['class'=>'error-message']);?>
                                </td>
                                <td></td>
                                <td></td>
                                <td>
                                    <button type="submit" class="btn btn-info btn-sm"><i class="fa fa-search"></i></button>
                                    <?php if(!empty(array_filter($sForm->getData()))) { ?>
                                        <a href="<?php echo $this->url('stock-warning');?>" class="btn btn-default btn-sm"><i class="fa fa-reply"></i></a>
                                    <?php } ?>
                                </td>
                            </tr>
                            <?php echo $this->form()->closeTag(); ?>
                            </thead>

                            <?php if($this->goodsList) foreach ($this->goodsList as $goods) { ?>
                                <tr>
                                    <td>
                                        <?php if (!empty($goods->getGoodsImage())) { ?><img src="<?php echo $this->storeHelper()->goodsImage($goods->getGoodsImage()); ?>" class="img-thumbnail" style="<?php echo $this->adminHelper()->defaultGoodsImageWidth(); ?>float:left;margin-right: 3px;"><?php } ?>
                                        <?php echo $this->escapeHtml($goods->getGoodsName()); ?>
                                    </td>
                                    <td><?php echo $this->escapeHtml($goods->getGoodsNumber()); ?></td>
                                    <td><?php echo empty($goods->getGoodsSpec()) ? $this->translate('无') : $this->escapeHtml($goods->getGoodsSpec()); ?></td>
                                    <td><?php echo $this->escapeHtml($goods->getGoodsCategory()->getGoodsCategoryName()); ?></td>
                                    <td><?php echo empty($goods->getBrand()) ? $this->translate('无') : $this->escapeHtml($goods->getBrand()->getBrandName()); ?></td>
                                    <td>
                                        <?php if($goods->getGoodsStock() > 0) { ?>
                                            <?php echo $goods->getGoodsStock(); ?>
                                        <?php } else { ?>
                                            <?php echo $this->translate('无'); ?>
                                        <?php } ?>
                                    </td>
                                    <td><?php echo $this->warningMinNum; ?></td>
                                    <td><?php echo $this->warningMaxNum; ?></td>
                                </tr>
                            <?php } ?>
                        </table>
                    </div>
                    <div class="box-footer clearfix">
                        <?php echo $this->paginationControl($this->goodsList, 'Sliding', 'layout/page', ['route' => 'stock-warning']); ?>
                    </div>
                </div>

            </div>
        </div>

    </section>
</div>